package Tree116;
import java.util.*;
//判断是不是二叉搜索树
public class IsValibStTree {
    static class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;
    public TreeNode(int val) {
      this.val = val;
    }
  }
  int pre=Integer.MIN_VALUE;
        public boolean isValidBST (TreeNode root) {
            if(root==null){
                return true;
            }
            if(!isValidBST(root.left)){
                return false;
            }
            if(root.val<pre){
                return false;
            }
            pre=root.val;
            return isValidBST(root.right);
        }

}
